<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8" isErrorPage="true"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

response.setStatus(HttpServletResponse.SC_OK);
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>页面出错误了</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">

  </head>
  
  <body>
  	<div style="margin:80px 380px; text-align:center; color:red; width:520px;">
		<!-- 错误图片 -->
  		<img src="images/error500.jpg" width="260px"/>
  		<div style="height:20px;"></div>
  		<!--  获取异常信息 -->
		<div style="text-align:left;">
		 	<% 
				//错误时间，只需要精确到日即可
				Calendar date = Calendar.getInstance();
				String today = date.get(Calendar.YEAR) + "/" + (date.get(Calendar.MONTH)+1)
				+ "/" + date.get(Calendar.DATE);
				//产生一个随机数，当作出现的异常ID
				Random md = new Random();
				int logId = md.nextInt(1000);
				out.println("程序运行时出现异常！请将出现异常的时间、错误编码报告给网站管理员<br/>");
				out.print("时间：" + today + "<br/>错误编号：" + logId);
				//将异常保存到log文件
				//application.log("发生异常时间：" + today + "异常编号：" + logId + "，错误原因："
					//	+ exception.getMessage());
			%>
		</div>
		<div style="height:30px;"></div>
  		<button onclick="javascript:history.go(-1)" style="background:#C30; width:100px; height:38px; color:#FFF; border:none; font-weight:bold;">返回</button>
  	</div>
  </body>
</html>
